Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pretty formatting for types #6

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Add pretty formatting for types #6

merged 1 commit into from
Oct 4, 2023

Conversation

virtuald
Copy link
Member

@virtuald virtuald commented Jan 5, 2021

I like it, but is it too clever? Open to suggestions.

Normal string formatting converts to the canonical expected representation, but if you want to make a declaration then you need to either call __format__ directly, or you can pass a format spec with the name in it (f"{type:name}").

Copy link
Member

@auscompgeek auscompgeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling it format(decltype, "name") to just get a declaration with a name seems a bit weird. Perhaps it should be a method and have the string formatting as a convenience?

cxxheaderparser/types.py Outdated Show resolved Hide resolved
@virtuald
Copy link
Member Author

virtuald commented Jan 8, 2021

It's true, the name format thing is a bit weird.

@virtuald
Copy link
Member Author

virtuald commented Jan 9, 2021

@trelau if you have any thoughts about this your input is welcome

@virtuald
Copy link
Member Author

Coming back to this, I still don't think this is the right fit. In particular, there are several elements that one could format in one of several different ways depending on what you wanted.

@virtuald
Copy link
Member Author

Changed to format and format_decl functions instead of __str__ and __format__.

@virtuald virtuald force-pushed the fmt-types branch 2 times, most recently from 6b78c5e to f988ff1 Compare October 2, 2023 05:51
@virtuald virtuald merged commit 1758155 into main Oct 4, 2023
24 checks passed
@virtuald virtuald deleted the fmt-types branch October 4, 2023 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants